import matplotlib.pyplot as plt
from matplotlib.pyplot import MultipleLocator

plt.rcParams['font.sans-serif'] = ['KaiTi']
plt.rcParams['font.serif'] = ['KaiTi']


def china_data():
    x1 = []
    y1 = [41, 41, 41, 45, 62, 198, 275, 291, 440, 574, 835, 1297, 1985, 2761, 4535, 5997, 7736, 9720, 11821, 14411, 17238, 20471, 24363, 28060, 31211, 34598, 37251, 40235, 42708, 44730, 59882, 63932, 66576, 68584, 70635, 72528, 74279, 75002, 75993, 76392, 77041, 77262, 77779, 78190, 78630, 78959, 79389, 79968, 80174, 80302, 80422, 80565, 80710, 80813, 80859, 80904, 80924, 80955, 80992, 81003, 81021, 81048, 81077, 81116, 81151, 81235, 81300, 81416, 81498, 81600, 81747, 81846, 81960, 82078, 82213, 82341]
    y2 = [1, 1, 2, 2, 2, 3, 4, 6, 9, 17, 25, 41, 56, 80, 106, 132, 170, 213, 259, 304, 361, 425, 491, 564, 637, 723, 812, 909, 1017, 1114, 1368, 1381, 1524, 1666, 1772, 1870, 2006, 2121, 2239, 2348, 2445, 2595, 2666, 2718, 2747, 2791, 2838, 2873, 2915, 2946, 2984, 3015, 3045, 3073, 3100, 3123, 3140, 3162, 3173, 3180, 3194, 3204, 3218, 3231, 3242, 3250, 3253, 3261, 3267, 3276, 3283, 3287, 3293, 3298, 3301, 3306]
    

    
    i = 0
    for i in range(len(y1)):
        x1.append(i+1)
        i+=1
    print(y1)
    print(y2)
    
    plt.figure(num = "疫情全国累计图")
    plt.xlabel("日期，2019.1.20至今")
    plt.ylabel("人数")
    ax = plt.gca()
    ax.spines["top"].set_color("none")
    ax.spines["right"].set_color("none")
    ax.xaxis.set_ticks_position("bottom")
    ax.yaxis.set_ticks_position("left")
    plt.xlim(1,(len(x1)+1))
    plt.ylim(0,90000)
    plt.plot(x1,y1,label = "全国累计确诊",color = "red")
    plt.plot(x1,y2,label = "全国累计死亡",color = "black")
    plt.xticks([])
    plt.legend()
    plt.show()


def italy_data():
    datas = get_data3()["data"]
    x1 = []
    y1 = []
    y2 = []
    i = 0
    for data in datas:
        x1.append(i+1)
        y1.append(int(data["confirm"]))
        y2.append(int(data["dead"]))
        i+=1
    print(y1)
    print(y2)
    print(len(y1))
    plt.figure(num = "疫情意大利累计图")
    plt.xlabel("日期，2019.1.31至今")
    plt.ylabel("人数")
    y_major_locator=MultipleLocator(10000)
    ax = plt.gca()
    ax.spines["top"].set_color("none")
    ax.spines["right"].set_color("none")
    ax.xaxis.set_ticks_position("bottom")
    ax.yaxis.set_ticks_position("left")
    ax.yaxis.set_major_locator(y_major_locator)
    plt.xlim(1,(len(x1)+1))
    plt.ylim(0,100000)
    plt.plot(x1,y1,label = "意大利累计确诊",color = "red")
    plt.plot(x1,y2,label = "意大利累计死亡",color = "black")
    plt.xticks([])
    plt.legend()
    plt.show()

def germany_data():
    datas = get_data4()["data"]
    x1 = []
    y1 = []
    y2 = []
    i = 0
    for data in datas:
        x1.append(i+1)
        y1.append(int(data["confirm"]))
        y2.append(int(data["dead"]))
        i+=1
    print(y1)
    print(y2)
    plt.figure(num = "疫情德国累计图")
    plt.xlabel("日期，2019.1.31至今")
    plt.ylabel("人数")
    y_major_locator=MultipleLocator(10000)
    ax = plt.gca()
    ax.spines["top"].set_color("none")
    ax.spines["right"].set_color("none")
    ax.xaxis.set_ticks_position("bottom")
    ax.yaxis.set_ticks_position("left")
    ax.yaxis.set_major_locator(y_major_locator)
    plt.xlim(1,(len(x1)+1))
    plt.ylim(0,50000)
    plt.plot(x1,y1,label = "德国累计确诊",color = "red")
    plt.plot(x1,y2,label = "德国累计死亡",color = "black")
    plt.xticks([])
    plt.legend()
    plt.show()


def total_data():
    datas2 = get_data2()["chinaDayList"]
    datas3 = get_data3()["data"]
    datas4 = get_data4()["data"]
    x1 = []
    x2 = []
    y1 = []
    y2 = []
    y3 = []
    y4 = []
    y5 = []
    y6 = []
    i = 0
    for data in datas2:
       
        if i >=17:
            x1.append(i-16)
            y1.append(int(data["confirm"]))
            y2.append(int(data["dead"]))
        i+=1
    print(y1)
    i = 0
    for data in datas3:
        x2.append(i+1)
        y3.append(int(data["confirm"]))
        y4.append(int(data["dead"]))
        i+=1
    print(len(x2))
    i = 0
    for data in datas4:
        if i>=3:
            y5.append(int(data["confirm"]))
            y6.append(int(data["dead"]))
        
        i+=1

    plt.figure(num = "总图")
    plt.xlabel("日期，2019.1.31至今")
    plt.ylabel("人数")
    y_major_locator=MultipleLocator(10000)
    ax = plt.gca()
    ax.spines["top"].set_color("none")
    ax.spines["right"].set_color("none")
    ax.xaxis.set_ticks_position("bottom")
    ax.yaxis.set_ticks_position("left")
    ax.yaxis.set_major_locator(y_major_locator)
    plt.xlim(1,(len(x1)+1))
    plt.ylim(0,100000)
    plt.plot(x1,y1,label = "中国累计确诊",color = "red")
    plt.plot(x1,y2,label = "中国累计死亡",color = "#e8b004")
    plt.plot(x2,y3,label = "意大利累计确诊",color = "green")
    plt.plot(x1,y4,label = "意大利累计死亡",color = "gray")
    plt.plot(x1,y5,label = "德国累计确诊",color = "blue")
    plt.plot(x1,y6,label = "德国累计死亡",color = "black")
    plt.xticks([])
    plt.legend()
    plt.show()
china_data()
